package 第二章数据结构.Trie字典树.id143最大异或对;

import java.util.Scanner;

public class Main {
    static TireNode root = new TireNode();
    static  int max = 0;
    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int[] nums = new int[n];
        for(int i = 0;i<n;i++){
            nums[i] = scanner.nextInt();
        }
        for(int i = 0;i<n;i++){
            insert(root , nums[i]);
        }
        for(int i = 0;i<n;i++){
            int ret =  query(root ,nums[i]);
            max = Math.max(ret ^ nums[i], max);
        }
        System.out.println(max);
    }

    static class TireNode{
        TireNode[] sons = new TireNode[2];
        boolean isEnd = false;
        int cnt = 0;
    }

    static void insert(TireNode root , int num){
        TireNode cur = root;
        for(int i = 31; i>=0 ;i--){
            int x = (num >> i) & 1;
            if (cur.sons[x] == null) {
                cur.sons[x] = new TireNode();
            }
            cur = cur.sons[x];
        }
    }
    //查询与num异或最大的数
    static int query(TireNode root , int num){
        TireNode cur = root;
        int ret = 0;
        for(int i = 31;i>=0;i--){
            int x = (num >> i) & 1;
            //找每一位相反的
            int x_ =  1 - x;
            if(cur.sons[x_] != null){
                ret  += x_ << i;
                cur = cur.sons[x_];
            }else {
                ret += x << i;
                cur = cur.sons[x];
            }
        }
        return ret;
    }
}
